<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Class My_Email
 */
class MyEmail
{
    private $myemail;
    private $CI;

    public function __construct()
    {
        $this->CI = & get_instance();
        $this->CI->load->library('Email');
        $this->CI->config->load('myemail');
		$this->myemail = $this->CI->config->item('myemail');

        $this->CI->email->initialize($this->myemail);
    }

    /**
     * 发送短信
     *
     * @param $toEmail
     * @param $subject
     * @param $content
     */
    public function sendEmail($toEmail, $subject, $content)
    {
        $this->CI->email->from($this->myemail['smtp_user'], $this->myemail['email_sender']);
        $this->CI->email->to($toEmail);

        $this->CI->email->subject($subject);
        $this->CI->email->message($content);

        $res = $this->CI->email->send();
        if($res){
            return true;
        }else{
            return false;
        }
    }
}
